package com.company.zhishidian.stream;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;

public class TestZ {
    public static void main(String[] args) throws IOException {
        BufferedReader br = Files.newBufferedReader(Paths.get("pkg/cars.rtf"));
//        br.lines().flatMap(s -> {String str[] = s.split("，");new Car(str[0],str[1],Integer.parseInt(str[2]))});
        List<Car> list = br.lines().map((line)->{
            String [] arr = line.split(",");
            return new Car(arr[0],arr[1],Integer.parseInt(arr[2]));
        }).collect(Collectors.toList());

    }
}
class Car{
    private String name;
    private String color;
    private int money;

    public Car(String name, String color, int money) {
        this.name = name;
        this.color = color;
        this.money = money;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    @Override
    public String toString() {
        return "Car{" +
                "name='" + name + '\'' +
                ", color='" + color + '\'' +
                ", money=" + money +
                '}';
    }
}